Current File : //usr/lib/python3/dist-packages/twisted/python/test/__pycache__/test_util.cpython-312.pyc
�

Ϫ�fH���$�dZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
mZddlm
Z
	ddlZddlZeZeZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlm Z ddl!m"Z"dd
l#m$Z$m%Z%ddl&m'Z(e ejR�jU�Z+Gd�de%�Z,Gd�de%�Z-Gd�de%�Z.e
e/edd�d�Gd�de%��Z0Gd�de%�Z1Gd�de%�Z2Gd�de%�Z3Gd�d e�Z4e
ejje�d!�Gd"�d#e%��Z6Gd$�d%e%�Z7Gd&�d'e%�Z8Gd(�d)ejr�Z:Gd*�d+ejr�Z;Gd,�d-e:�Z<Gd.�d/�Z=Gd0�d1�Z>Gd2�d3e%�Z?e
e/ed4d�d5�Gd6�d7e%��Z@e
ej�d8�Gd9�d:e%��ZBGd;�d<e%�ZCGd=�d>e%�ZDGd?�d@e%�ZEGdA�dBe%�ZFy#e$rdZdZY���wxYw)Cz#
Tests for L{twisted.python.util}.
�N)�Iterable�Mapping�MutableMapping�Sequence)�skipIf)�reactor)�Deferred)�ProcessDone)�IReactorProcess)�ProcessProtocol)�util)�FilePath)�MockOS)�FailTest�TestCase)�suppressc�h�eZdZd�Zd�Zd�Zeedud�d��Zd�Z	ee
dud�d	��Zy)
�	UtilTestsc�Z�gd�}|jtj|�gd��y)N)�a��abr��r�rr�)rrrrrrr)�assertEqualr
�uniquify)�self�
listWithDupess  �?/usr/lib/python3/dist-packages/twisted/python/test/test_util.py�testUniqzUtilTests.testUniq+s!��@�
�������}�5�7Q�R�c�4�|jtjttdd��|jtjttdd��	tjttdd�td��#t$rYywxYw)Nrrz,util.raises didn't raise when it should have)�
assertTruer
�raises�ZeroDivisionError�divmod�assertFalse�	TypeErrorr�rs r!�
testRaiseszUtilTests.testRaises/sv��������$5�v�q�!�D�E�������%6���1�E�F�	K��K�K�	�6�1�a�0��I�J�J��!�	��	�s�  B�	B�Bc�N�|jtjd�d�y)��
        When L{uidFromString} is called with a base-ten string representation
        of an integer, it returns the integer.
        �100�dN)rr
�
uidFromStringr+s r!�test_uidFromNumericStringz#UtilTests.test_uidFromNumericString:���
	
����+�+�E�2�C�8r#Nz0Username/UID conversion requires the pwd module.c���tjtj��}|j	tj|j�|j�y)r.N)	�pwd�getpwuid�os�getuidrr
r1�pw_name�pw_uid)r�pwents  r!�test_uidFromUsernameStringz$UtilTests.test_uidFromUsernameStringA�;�����R�Y�Y�[�)������+�+�E�M�M�:�E�L�L�Ir#c�N�|jtjd�d�y)��
        When L{gidFromString} is called with a base-ten string representation
        of an integer, it returns the integer.
        r/r0N)rr
�
gidFromStringr+s r!�test_gidFromNumericStringz#UtilTests.test_gidFromNumericStringJr3r#z2Group Name/GID conversion requires the grp module.c���tjtj��}|j	tj|j�|j�y)r?N)	�grp�getgrgidr7�getgidrr
r@�gr_name�gr_gid)r�grents  r!�test_gidFromGroupnameStringz%UtilTests.test_gidFromGroupnameStringQr=r#)�__name__�
__module__�__qualname__r"r,r2rr5r<rArCrI�r#r!rr*s^��S�	K�9��C�4�K�K�L�J�M�J�9��C�4�K�M�N�J�O�Jr#rc��eZdZdZd�Zy)�NameToLabelTestsz#
    Tests for L{nameToLabel}.
    c��gd�}|D]6\}}tj|�}|j||d|�d|�d|����8y)zK
        Test the various kinds of inputs L{nameToLabel} supports.
        ))�f�F)�fo�Fo)�foo�Foo)�fooBarzFoo Bar)�	fooBarBazzFoo Bar BazznameToLabel(z) == z != N)r
�nameToLabelr)r�nameData�inp�out�gots     r!�test_nameToLabelz!NameToLabelTests.test_nameToLabel`sU��
��!�	V�H�C���"�"�3�'�C����S�#��c�W�E�#���S�G�'T�U�	Vr#N)rJrKrL�__doc__r^rMr#r!rOrO[s
���
Vr#rOc��eZdZdZd�Zy)�UntilConcludesTestsz:
    Tests for L{untilConcludes}, an C{EINTR} helper.
    c�l���fd�}dg�_d�_�jtj|dd�d��j�jd�dt
tg�_d�_�jtj|dd�d��j�jd�y)a
        L{untilConcludes} calls the function passed to it until the function
        does not raise either L{OSError} or L{IOError} with C{errno} of
        C{EINTR}.  It otherwise completes with the same result as the function
        passed to it.
        c����xjdz
c_�jj�}|�|tjd��||zS)NrzInterrupted system call!)�calls�
exceptions�pop�errno�EINTR)r�b�excrs   �r!rQz3UntilConcludesTests.test_uninterruptably.<locals>.f}sB����J�J�!�O�J��/�/�%�%�'�C����%�+�+�'A�B�B��q�5�Lr#Nrrrr�)rerdrr
�untilConcludes�OSError�IOError)rrQs` r!�test_uninterruptablyz(UntilConcludesTests.test_uninterruptablyus����	� �&�����
�����,�,�Q��1�5�q�9�������Q�'���'�2�����
�����,�,�Q��1�5�q�9�������Q�'r#N)rJrKrLr_rorMr#r!raraps���(r#rar8zgetuid/setuid not availablec�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	y)	�SwitchUIDTestsz&
    Tests for L{util.switchUID}.
    c��t�|_|jtd|j�|jtd|j�g|_y)Nr7�
initgroups)r�mockos�patchr
rs�initgroupsCallsr+s r!�setUpzSwitchUIDTests.setUp�s;���h����
�
�4��t�{�{�+��
�
�4��t���7�!��r#c�>�|jj||f�y)zK
        Save L{util.initgroups} calls in C{self.initgroupsCalls}.
        N)rv�append)r�uid�gids   r!rszSwitchUIDTests.initgroups�s��	
���#�#�S�#�J�/r#c��tjdd�|j|jdg�|j|jj
dg�y)zn
        L{util.switchUID} calls L{util.initgroups} and then C{os.setuid} with
        the given uid.
        ��.N�r}N)�setuidr})r
�	switchUIDrrvrt�actionsr+s r!�test_uidzSwitchUIDTests.test_uid�sH��
	
���u�d�#�����-�-�
��?�������,�,�/@�.A�Br#c��tjddd�|j|jdg�|j|jj
dg�y)z�
        L{util.switchUID} calls L{util.initgroups} and then C{os.seteuid} with
        the given uid if the C{euid} parameter is set to C{True}.
        r}NTr~)r
r�rrvrt�seteuidCallsr+s r!�	test_euidzSwitchUIDTests.test_euid�sH��
	
���u�d�D�)�����-�-�
��?�������1�1�E�7�;r#c���|jj�}tj|d�|j	|j
g�|j	|jjg�|jtjg�}|j	t|�d�|jd|z|dd�|jd|z|dd�y)z�
        If the current uid is the same as the uid passed to L{util.switchUID},
        then initgroups does not get called, but a warning is issued.
        Nrz&tried to drop privileges and setuid %ir�messagezbut uid is already %i)
rtr8r
r�rrvr��
flushWarnings�len�assertIn)rrz�currentWarningss   r!�test_currentUIDzSwitchUIDTests.test_currentUID�s���
�k�k� � �"�����s�D�!�����-�-�r�2�������,�,�b�1��,�,�d�n�n�-=�>������_�-�q�1��
�
�4�s�:��A��y�)�	
�	
�
�
�-��3�_�Q�5G�	�5R�Sr#c���|jj�}tj|dd�|j	|j
g�|j	|jjg�|jtjg�}|j	t|�d�|jd|z|dd�|jd|z|dd�y)z�
        If the current euid is the same as the euid passed to L{util.switchUID},
        then initgroups does not get called, but a warning is issued.
        NTrz'tried to drop privileges and seteuid %irr�zbut euid is already %i)
rt�geteuidr
r�rrvr�r�r�r�)r�euidr�s   r!�test_currentEUIDzSwitchUIDTests.test_currentEUID�s���
�{�{�"�"�$�����t�T�4�(�����-�-�r�2�������1�1�2�6��,�,�d�n�n�-=�>������_�-�q�1��
�
�5��<��A��y�)�	
�	
�
�
�.��5��q�7I�)�7T�Ur#N)
rJrKrLr_rwrsr�r�r�r�rMr#r!rqrq�s(���"�0�C�<�T�"Vr#rqc�.�eZdZdZd�Zd�Zd�Zd�Zd�Zy)�MergeFunctionMetadataTestsz-
    Tests for L{mergeFunctionMetadata}.
    c����t��t���fd�}d	�fd�	}tj||�}|j|dddd����y)
zt
        After merging C{foo}'s data into C{bar}, the returned function behaves
        as if it is C{bar}.
        c����S�NrM)�
foo_objects�r!rUzQMergeFunctionMetadataTests.test_mergedFunctionBehavesLikeMergeTarget.<locals>.foo�s	����r#�
c���|\}}�Sr�rM)	�x�yr�c�d�erri�
bar_objects	        �r!�barzQMergeFunctionMetadataTests.test_mergedFunctionBehavesLikeMergeTarget.<locals>.bar�s����F�Q���r#rr)rr)�quuxN)r�)�objectr
�mergeFunctionMetadata�assertIs)rrUr��bazr�r�s    @@r!�)test_mergedFunctionBehavesLikeMergeTargetzDMergeFunctionMetadataTests.test_mergedFunctionBehavesLikeMergeTarget�sJ���
�X�
��X�
�	�	��(�(��c�2���
�
�c�!�Q��R�0�*�=r#c��d�}d�}d|_tj||�}|j|j|j�y)zd
        Merging C{foo} into C{bar} returns a function with C{foo}'s
        C{__module__}.
        c��yr�rMrMr#r!rUz;MergeFunctionMetadataTests.test_moduleIsMerged.<locals>.foo����r#c��yr�rMrMr#r!r�z;MergeFunctionMetadataTests.test_moduleIsMerged.<locals>.bar�r�r#zsomewhere.elseN)rKr
r�r�rrUr�r�s    r!�test_moduleIsMergedz.MergeFunctionMetadataTests.test_moduleIsMerged�s?��	�	�*����(�(��c�2�����������8r#c��d�}d�}tj||�}|j|j|j�y)zX
        Merging C{foo} into C{bar} returns a function with C{foo}'s docstring.
        c��y)z&
            This is foo.
            NrMrMr#r!rUz>MergeFunctionMetadataTests.test_docstringIsMerged.<locals>.foo��r#c��y)z&
            This is bar.
            NrMrMr#r!r�z>MergeFunctionMetadataTests.test_docstringIsMerged.<locals>.barr�r#N)r
r�rr_r�s    r!�test_docstringIsMergedz1MergeFunctionMetadataTests.test_docstringIsMerged�s8��
	�
	�
�(�(��c�2��������c�k�k�2r#c��d�}d�}tj||�}|j|j|j�y)zS
        Merging C{foo} into C{bar} returns a function with C{foo}'s name.
        c��yr�rMrMr#r!rUz9MergeFunctionMetadataTests.test_nameIsMerged.<locals>.foor�r#c��yr�rMrMr#r!r�z9MergeFunctionMetadataTests.test_nameIsMerged.<locals>.barr�r#N)r
r�rrJr�s    r!�test_nameIsMergedz,MergeFunctionMetadataTests.test_nameIsMergeds8��
	�	��(�(��c�2��������s�|�|�4r#c�X�d�}d|_d|_d�}d|_d|_tj||�}|j|j|j�|j|j|j�|j|j|j�y)zv
        Merging C{foo} into C{bar} returns a function with C{bar}'s
        dictionary, updated by C{foo}'s.
        c��yr�rMrMr#r!rUzGMergeFunctionMetadataTests.test_instanceDictionaryIsMerged.<locals>.foo$r�r#rrc��yr�rMrMr#r!r�zGMergeFunctionMetadataTests.test_instanceDictionaryIsMerged.<locals>.bar*r�r#rrN)rrir�r
r�rr�s    r!�test_instanceDictionaryIsMergedz:MergeFunctionMetadataTests.test_instanceDictionaryIsMergeds���	�������	��������(�(��c�2�����������&����������&����������&r#N)	rJrKrLr_r�r�r�r�r�rMr#r!r�r��s ���>�$9�"3�$5�'r#r�c��eZdZdZd�Zy)�OrderedDictTestsz(
    Tests for L{util.OrderedDict}.
    c���ddlm}||j|jg��}|j	|ddd�|j	|ddt
�|j	t
|�d�y)	z4
        L{util.OrderedDict} is deprecated.
        r)�OrderedDict��offendingFunctionsr�zftwisted.python.util.OrderedDict was deprecated in Twisted 15.5.0: Use collections.OrderedDict instead.�categoryrN)�twisted.python.utilr�r��test_deprecatedr�DeprecationWarningr�)rr�r�s   r!r�z OrderedDictTests.test_deprecated;sx��	4���,�,��AU�AU�@V�,�W������A��y�)�
;�	
�
	
�����+�J�7�9K�L�����_�-�q�1r#N)rJrKrLr_r�rMr#r!r�r�6s���2r#r�c�.�eZdZdZd�Zd�Zd�Zd�Zd�Zy)�InsensitiveDictTestsz,
    Tests for L{util.InsensitiveDict}.
    c�$�tj�}|jt|t��|jt|t
��|jt|t��|jt|t��y)zN
        L{util.InsensitiveDict} implements L{typing.MutableMapping}.
        N)	r
�InsensitiveDictr%�
isinstancerrrr)r)r�dcts  r!�test_abczInsensitiveDictTests.test_abcRs`���"�"�$�����
�3��1�2����
�3��0�1����
�3��7�8�����C��2�3r#c��tjddddid�d��}|j|dddi�|j|dd�|j|j�|�|j|d|j	d��|jd|�|jd|�t
t|�|tjd	��}|j||�gd
�}|D]G}|j||j��|j|||f|j���I|jt|�t|��|d=|d=|j|j�dg�y)zr
        L{util.InsensitiveDict} preserves the case of keys if constructed with
        C{preserve=True}.
        r�rr�rVr�fnz��preserver�rUrV)r�r�)rVr�rN)r
r�r�copy�getr��eval�repr�keys�itemsr�)rr��resultr�r�s     r!�
test_preservez"InsensitiveDictTests.test_preserve\sT��
�"�"�5�Q��1�v�#F�QR�S������U��a��V�,�����U��U�+��������S�)�����U��S�W�W�U�^�4��
�
�a����
�
�e�S�!����I��#'�#7�#7�
�
��	
�����%� ���	4�A��M�M�!�S�X�X�Z�(��M�M�1�c�!�f�+�s�y�y�{�3�	4�	
����T��C��H�-���F���J��������e�W�-r#c�t�tjddddid�d��}gd�}|D]G}|j||j��|j|||f|j	���I|jt
|�t
|��|d=|d=|j|j�d	g�y
)z|
        L{util.InsensitiveDict} does not preserves the case of keys if
        constructed with C{preserve=False}.
        r�rrr�rr�)rUr�rrUr�N)r
r�r�r�r�rr�)rr�r�r�s    r!�test_noPreservez$InsensitiveDictTests.test_noPreserve{s���
�"�"�5�Q��1�v�#F�QR�S�� ���	4�A��M�M�!�S�X�X�Z�(��M�M�1�c�!�f�+�s�y�y�{�3�	4�	
����T��C��H�-���F���J��������e�W�-r#c��tjd��}d|d<|j|dd�|j|j�dg�y)z4
        Unicode keys are case insensitive.
        Fr�rrV�FOOrUN�r
r�rr��rr�s  r!�test_unicodez!InsensitiveDictTests.test_unicode�sI��
� � �%�0����%������5��1�%��������E�7�+r#c��tjd��}d|d<|j|dd�|j|j�dg�y)z2
        Bytes keys are case insensitive.
        Fr�rsFoosFOOsfooNr�r�s  r!�
test_byteszInsensitiveDictTests.test_bytes�sI��
� � �%�0����&�	�����6��A�&��������F�8�,r#N)	rJrKrLr_r�r�r�r�r�rMr#r!r�r�Ms ���4�.�>
.�,�-r#r�c�"�eZdZdZd�Zd�Zd�Zy)�PasswordTestingProcessProtocolz�
    Write the string C{"secret\n"} to a subprocess and then collect all of
    its output and fire a Deferred with it when the process ends.
    c�H�g|_|jjd�y)Nssecret
)�output�	transport�writer+s r!�connectionMadez-PasswordTestingProcessProtocol.connectionMade�s����������[�)r#c�>�|jj||f�yr�)r�ry)r�fdr�s   r!�childDataReceivedz0PasswordTestingProcessProtocol.childDataReceived�s�������B��<�(r#c�R�|jj||jf�yr�)�finished�callbackr�)r�reasons  r!�processEndedz+PasswordTestingProcessProtocol.processEnded�s���
�
�������4�5r#N)rJrKrLr_r�r�r�rMr#r!r�r��s���
*�)�6r#r�z,Process support required to test getPasswordc��eZdZd�Zy)�GetPasswordTestsc	�6��t�}t�|_tj|t
t
ddgdtjjtj�jd�i���fd�}|jj|�S)a.
        Making sure getPassword accepts a password from standard input by
        running a child process which uses getPassword to read in a string
        which it then writes it out again.  Write a string to the child
        process and then read one and make sure it is the right string.
        s-csjimport sys
from twisted.python.util import getPassword
sys.stdout.write(getPassword())
sys.stdout.flush()
s
PYTHONPATH�utf8)�envc�^��|\}}|jt��jd|�y)N)rssecret)�trapr
r�)r�r�r�rs   �r!�processFinishedz4GetPasswordTests.test_stdin.<locals>.processFinished�s'���%��V�V��K�K��$��M�M�.�&�1r#)
r�r	r�r�spawnProcess�pyExer7�pathsep�join�sys�path�encode�addCallback)r�pr�s`  r!�
test_stdinzGetPasswordTests.test_stdin�s|���
+�,���Z��
����
����,�		
���
�
������ 9� @� @�� H�I�	
� 	2�
�z�z�%�%�o�6�6r#N)rJrKrLrrMr#r!r�r��s��
7r#r�c��eZdZd�Zy)�SearchUpwardsTestsc��tjd�tdd�j�tdd�j�tdd�j�tjd�tjd�tjd�tjd	�tjdd
gddg�
�}tjjd�tjz}|j||�tjd�tjdd
gddg�
�}d}|j||�y)Nzsearchupwards/a/b/czsearchupwards/foo.txt�wzsearchupwards/a/foo.txtzsearchupwards/a/b/c/foo.txtzsearchupwards/barzsearchupwards/bamzsearchupwards/a/barzsearchupwards/a/b/bamzfoo.txtr��bam)�files�dirs�
searchupwards)
r7�makedirs�open�close�mkdirr
rr��abspath�sepr�shutil�rmtree)r�actual�expecteds   r!�testSearchupwardsz$SearchUpwardsTests.testSearchupwards�s	��
���)�*��
$�c�*�0�0�2��
&��,�2�2�4��
*�C�0�6�6�8�
���$�%�
���$�%�
���&�'�
���(�)��#�#�!�)��E�5�>�
���7�7�?�?�?�3�b�f�f�<�������*��
�
�o�&��#�#�!�)��E�5�>�
���������*r#N)rJrKrLrrMr#r!rr�s��+r#rc�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�IntervalDifferentialTestsc��ttjgd��}td�D]}|j	t|�d��y)Nr�r0�r�N��iterr
�IntervalDifferential�ranger�next�rr��is   r!�testDefaultz%IntervalDifferentialTests.testDefault�s@����*�*�2�r�2�3���s��	2�A����T�!�W�j�1�	2r#c��ttjdgd��}td�D]}|j	t|�d��y)Nrkr�r0�rkrrrs   r!�
testSinglez$IntervalDifferentialTests.testSingle�sB����*�*�A�3��3�4���s��	.�A����T�!�W�f�-�	.r#c���ttjddgd��}td�D�]G}|j	t|�d�|j	t|�d�|j	t|�d�|j	t|�d�|j	t|�d	�|j	t|�d�|j	t|�d
�|j	t|�d�|j	t|�d�|j	t|�d
�|j	t|�d�|j	t|�d���Jy)Nrk�r�r0r!�rr�rr)rr�rr�rr�rr)rr�rr�rrrrs   r!�testPairz"IntervalDifferentialTests.testPair�s ����*�*�A�q�6�2�6�7���s��	.�A����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-�	.r#c�l�ttjgd�d��}td�D�]}|j	t|�d�|j	t|�d�|j	t|�d�|j	t|�d�|j	t|�d�|j	t|�d�|j	t|�d�|j	t|�d�|j	t|�d�|j	t|�d�|j	t|�d�|j	t|�d�|j	t|�d�|j	t|�d�|j	t|�d�|j	t|�d�|j	t|�d�|j	t|�d�|j	t|�d���y)	N)rrrkr�r0r*r+)rrr')rrrrs   r!�
testTriplez$IntervalDifferentialTests.testTriples�����*�*�9�b�9�:���s��	.�A����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-����T�!�W�f�-�'	.r#c�l�ttjgd��}|jt	|�d�|jd�|jt	|�d�|jt	|�d�|jd�|jt	|�d�|jt	|�d�|jt	|�d�|jt	|�d�|jt	|�d�|jt	|�d�y)Nr�rrr&rr+)rr
rrr�addIntervalr�s  r!�
testInsertz$IntervalDifferentialTests.testInserts�����*�*�2�r�2�3������a��*�-�	�
�
�a������a��&�)�����a��&�)�	�
�
�a������a��&�)�����a��&�)�����a��&�)�����a��&�)�����a��&�)�����a��&�)r#c��ttjddgd��}|jt	|�d�|jt	|�d�|jt	|�d�|jd�|jt	|�d�|jt	|�d�|jd�|jt	|�d	�|j
t|j
d�y)
Nrrkr�r&r%r'r)r!r)rr
rrr�removeInterval�assertRaises�
ValueErrorr�s  r!�
testRemovez$IntervalDifferentialTests.testRemove+s�����*�*�A�q�6�2�6�7������a��&�)�����a��&�)�����a��&�)�	���������a��&�)�����a��&�)�	���������a��*�-����*�a�&6�&6��;r#N)	rJrKrLrr"r,r.r1r6rMr#r!rr�s ��2�
.�
.� .�.*�
<r#rc��eZdZdZdZd�Zy)�Recordz8
    Trivial user of L{FancyEqMixin} used by tests.
    �rric� �||_||_yr�r9�rrris   r!�__init__zRecord.__init__?��������r#N�rJrKrLr_�compareAttributesr<rMr#r!r8r88����#��r#r8c��eZdZdZdZd�Zy)�DifferentRecordzL
    Trivial user of L{FancyEqMixin} which is not related to L{Record}.
    r9c� �||_||_yr�r9r;s   r!r<zDifferentRecord.__init__Kr=r#Nr>rMr#r!rBrBDr@r#rBc��eZdZdZy)�
DerivedRecordz@
    A class with an inheritance relationship to L{Record}.
    N)rJrKrLr_rMr#r!rErEPs��r#rEc� �eZdZdZdedefd�Zy)�EqualToEverythingzQ
    A class the instances of which consider themselves equal to everything.
    �other�returnc��y)NTrM�rrHs  r!�__eq__zEqualToEverything.__eq__[s��r#N�rJrKrLr_r��boolrLrMr#r!rGrGVs����F��t�r#rGc� �eZdZdZdedefd�Zy)�EqualToNothingzN
    A class the instances of which consider themselves equal to nothing.
    rHrIc��y)NFrMrKs  r!rLzEqualToNothing.__eq__ds��r#NrMrMr#r!rPrP_s����F��t�r#rPc�F�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zy)�
EqualityTestsz$
    Tests for L{FancyEqMixin}.
    c��Gd�dtj�}|j|�|�k(�|j|�|�k7�|�}|j||k(�|j||k7�y)z�
        Instances of a class which mixes in L{FancyEqMixin} but which
        defines no comparison attributes compare by identity.
        c��eZdZy)�*EqualityTests.test_identity.<locals>.EmptyN)rJrKrLrMr#r!�EmptyrVss��r#rWN)r
�FancyEqMixinr)r%)rrW�emptys   r!�
test_identityzEqualityTests.test_identitymsk��	�D�%�%�	�	
�����E�G�+�,������5�7�*�+����������'�����%��(r#c�D�|jtdd�tdd�k(�|jtdd�tdd�k(�|jtdd�tdd�k(�|jtdd�tdd�k(�y)z�
        Instances of a class which mixes in L{FancyEqMixin} should compare
        equal if all of their attributes compare equal.  They should not
        compare equal if any of their attributes do not compare equal.
        rrrrN)r%r8r)r+s r!�
test_equalityzEqualityTests.test_equality|s~��	
����q�!���q�!��4�5������1����1��5�6������1����1��5�6������1����1��5�6r#c�D�|jtdd�tdd�k7�|jtdd�tdd�k7�|jtdd�tdd�k7�|jtdd�tdd�k7�y)z
        Inequality between instances of a particular L{record} should be
        defined as the negation of equality.
        rrrrN)r)r8r%r+s r!�test_unequalityzEqualityTests.test_unequality�sz��
	
�����1����1��5�6�����q�!���q�!��4�5�����q�!���q�!��4�5�����q�!���q�!��4�5r#c�T�|jtdd�tdd�k(�y)zo
        Instances of different classes which mix in L{FancyEqMixin} should not
        compare equal.
        rrN)r)r8rBr+s r!�test_differentClassesEqualityz+EqualityTests.test_differentClassesEquality�s$��
	
�����1����A�)>�>�?r#c�T�|jtdd�tdd�k7�y)zm
        Instances of different classes which mix in L{FancyEqMixin} should
        compare unequal.
        rrN)r%r8rBr+s r!�test_differentClassesInequalityz-EqualityTests.test_differentClassesInequality�s"��
	
����q�!����1�(=�=�>r#c�D�|jtdd�tdd�k(�|jtdd�tdd�k(�|jtdd�tdd�k(�|jtdd�tdd�k(�y)z�
        An instance of a class which derives from a class which mixes in
        L{FancyEqMixin} should compare equal to an instance of the base class
        if and only if all of their attributes compare equal.
        rrrrN)r%r8rEr)r+s r!�test_inheritedClassesEqualityz+EqualityTests.test_inheritedClassesEquality�s���	
����q�!��
�a��(;�;�<������1���q�!�)<�<�=������1���q�!�)<�<�=������1���q�!�)<�<�=r#c�D�|jtdd�tdd�k7�|jtdd�tdd�k7�|jtdd�tdd�k7�|jtdd�tdd�k7�y)z�
        An instance of a class which derives from a class which mixes in
        L{FancyEqMixin} should compare unequal to an instance of the base
        class if any of their attributes compare unequal.
        rrrrN)r)r8rEr%r+s r!�test_inheritedClassesInequalityz-EqualityTests.test_inheritedClassesInequality�s~��	
�����1���q�!�)<�<�=�����q�!��
�a��(;�;�<�����q�!��
�a��(;�;�<�����q�!��
�a��(;�;�<r#c��|jtdd�t�k(�|jtdd�t	�k(�y)z�
        The right-hand argument to the equality operator is given a chance
        to determine the result of the operation if it is of a type
        unrelated to the L{FancyEqMixin}-based instance on the left-hand
        side.
        rrN)r%r8rGr)rPr+s r!�(test_rightHandArgumentImplementsEqualityz6EqualityTests.test_rightHandArgumentImplementsEquality�s;��	
����q�!��(9�(;�;�<������1���)9�9�:r#c��|jtdd�t�k7�|jtdd�t	�k7�y)z�
        The right-hand argument to the non-equality operator is given a
        chance to determine the result of the operation if it is of a type
        unrelated to the L{FancyEqMixin}-based instance on the left-hand
        side.
        rrN)r)r8rGr%rPr+s r!�*test_rightHandArgumentImplementsUnequalityz8EqualityTests.test_rightHandArgumentImplementsUnequality�s;��	
�����1��):�)<�<�=�����q�!���(8�8�9r#N)
rJrKrLr_rZr\r^r`rbrdrfrhrjrMr#r!rSrShs5���
)�	7�6�@�?�	>�	=�;�:r#rSr�zgeteuid/seteuid not availablec�L�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
y)
�RunAsEffectiveUserTestsz;
    Test for the L{util.runAsEffectiveUser} function.
    c�z�t�|_|jtd|jj�|jtd|jj
�|jtd|jj�|jtd|jj�y)Nr��getegid�seteuid�setegid)rrtrur7r�rnrorpr+s r!rwzRunAsEffectiveUserTests.setUp�ss���h����
�
�2�y�$�+�+�"5�"5�6��
�
�2�y�$�+�+�"5�"5�6��
�
�2�y�$�+�+�"5�"5�6��
�
�2�y�$�+�+�"5�"5�6r#c���|j||k(xs||jjdk(�|j||k(xs||jjdk(�y)zF
        Check if wanted UID/GID matched start or saved ones.
        ���N)r%rtr��setegidCalls)r�startUID�startGID�wantUID�wantGIDs     r!�_securedFunctionz(RunAsEffectiveUserTests._securedFunction�sZ��	
����8�+�V�w�$�+�+�:R�:R�SU�:V�/V�W�����8�+�V�w�$�+�+�:R�:R�SU�:V�/V�Wr#c�X�tjddd��}|j|d�y)zo
        L{util.runAsEffectiveUser} forwards the result obtained by calling the
        given function
        rc��y)NrrMrMr#r!�<lambda>z<RunAsEffectiveUserTests.test_forwardResult.<locals>.<lambda>�r�r#rN�r
�runAsEffectiveUserr�rr�s  r!�test_forwardResultz*RunAsEffectiveUserTests.test_forwardResult�s(��
�(�(��A�y�9�������#r#c�Z�tjddd�d�}|j|d�y)ze
        L{util.runAsEffectiveUser} pass the given parameters to the given
        function.
        rc��d|zS)NrrM)r�s r!r{z=RunAsEffectiveUserTests.test_takeParameters.<locals>.<lambda>�s
���Q��r#rrNr|r~s  r!�test_takeParametersz+RunAsEffectiveUserTests.test_takeParameters�s*��
�(�(��A���B�������#r#c�`�tjdddd�dd��}|j|d�y)	zg
        L{util.runAsEffectiveUser} pass the keyword parameters to the given
        function.
        rc��||z|zSr�rM)r�r��zs   r!r{zDRunAsEffectiveUserTests.test_takesKeyworkArguments.<locals>.<lambda>�s��1�q�5�1�9�r#rr)r�rNr(r|r~s  r!�test_takesKeyworkArgumentsz2RunAsEffectiveUserTests.test_takesKeyworkArguments�s.��
�(�(��A�/L�a�ST�U�������#r#c	�n�||j_||j_tj|||j
||||�|j
|jj|�|j
|jj|�g|j_g|j_y)z�
        Helper method checking the calls to C{os.seteuid} and C{os.setegid}
        made by L{util.runAsEffectiveUser}, when switching from startUID to
        wantUID and from startGID to wantGID.
        N)	rtr��egidr
r}rxrr�rs)rrtrurvrw�expectedUIDSwitches�expectedGIDSwitchess       r!�_testUIDGIDSwitchz)RunAsEffectiveUserTests._testUIDGIDSwitch�s���$�����#�����������!�!�����	
�	
������1�1�3F�G�������1�1�3F�G�#%���� �#%���� r#c	���|jddddgg�|jddddddgg�|jddddgddg�|jddddddgddg�y)zL
        Check UID/GID switches when current effective UID is root.
        rrN�r�r+s r!�	test_rootz!RunAsEffectiveUserTests.test_rootst��	
���q�!�Q��2�r�2����q�!�Q��A�q�6�2�6����q�!�Q��2��1�v�6����q�!�Q��A�q�6�A�q�6�:r#c	���|jddddddgg�|jddddgg�|jddddgd�ddg�|jddddgd�ddg�y)zP
        Check UID/GID switches when current effective UID is non-root.
        rr�rrrrr�rrrrNr�r+s r!�test_UIDz RunAsEffectiveUserTests.test_UIDsp��	
���q�!�Q��A�q�6�2�6����q�!�Q��2�r�2����q�!�Q��<�!�Q��@����q�!�Q��<�!�Q��@r#c	���|jddddgddg�|jddddgg�|jddddddgg�|jddddddgddg�y)zP
        Check UID/GID switches when current effective GID is non-root.
        rrrNr�r+s r!�test_GIDz RunAsEffectiveUserTests.test_GID&st��	
���q�!�Q��2��1�v�6����q�!�Q��2�r�2����q�!�Q��A�q�6�2�6����q�!�Q��A�q�6�A�q�6�:r#c	�`�|jddddddgddg�|jddddddgg�|jddddgd�ddg�|jddddgg�|jddddgd�g�|jddddgd�ddg�|jddddgd�ddg�y)zT
        Check UID/GID switches when current effective UID/GID is non-root.
        rrr�rr�Nr�r+s r!�test_UIDGIDz#RunAsEffectiveUserTests.test_UIDGID/s���	
���q�!�Q��A�q�6�A�q�6�:����q�!�Q��A�q�6�2�6����q�!�Q��<�!�Q��@����q�!�Q��2�r�2����q�!�Q��<��<����q�!�Q��<�!�Q��@����q�!�Q��<�!�Q��@r#N)rJrKrLr_rwrxrr�r�r�r�r�r�r�rMr#r!rlrl�s<���7�X�$�$�$�&�<;�A�;�
Ar#rlz.stdlib support for initgroups is not availablec��eZdZdZd�Zd�Zy)�InitGroupsTestsz'
    Tests for L{util.initgroups}.
    c���g��fd�}|jtd|�g}|jtd|j�tjt	j
�d�|j
�tjt	j
��jdfg�|j|�y)zc
        Calling L{util.initgroups} will call the underlying stdlib
        implmentation.
        c�,���j||f�yr�)ry)r�r�rds  �r!�mockInitgroupsz?InitGroupsTests.test_initgroupsInStdlib.<locals>.mockInitgroupsIs����L�L�!�Q�� r#�_initgroups�	setgroupsrN)rur
ryrsr7r8rr5r6r9r))rr��setgroupsCallsrds   @r!�test_initgroupsInStdlibz'InitGroupsTests.test_initgroupsInStdlibBs����
��	!�	
�
�
�4���7����
�
�4��n�&;�&;�<�����	�	��Q�'�����#�,�,�r�y�y�{�";�"C�"C�Q�!G� H�I�����(r#c�t�|jttjt	j
�d�y)zN
        Calling L{util.initgroups} with None for gid gives an error.
        N)r4r*r
rsr7r8r+s r!�test_initgroupsNoneGidz&InitGroupsTests.test_initgroupsNoneGidTs"��	
���)�T�_�_�b�i�i�k�4�Hr#N)rJrKrLr_r�r�rMr#r!r�r�<s���)�$Ir#r�c�<�eZdZdZd�Zd�Zeed��ge_y)�DeprecationTestsz;
    Tests for deprecations in C{twisted.python.util}.
    c��tj�|j|jg��}|j	|ddd�|j	|ddt
�|j	t
|�d�y)z6
        L{util.getPluginDirs} is deprecated.
        r�rr�zCtwisted.python.util.getPluginDirs is deprecated since Twisted 12.2.r�rN)r
�
getPluginDirsr��test_getPluginDirsrr�r��rr�s  r!r�z#DeprecationTests.test_getPluginDirs`s���	
�����,�,� $� 7� 7�8�-�
��	
����A��y�)�T�	
�	
�����+�J�7�9K�L�����_�-�q�1r#c��tj�|j|jg��}|j	|ddd�|j	|ddt
�|j	t
|�d�y)z5
        L{util.addPluginDir} is deprecated.
        r�rr�zBtwisted.python.util.addPluginDir is deprecated since Twisted 12.2.r�rN)r
�addPluginDirr��test_addPluginDirrr�r�r�s  r!r�z"DeprecationTests.test_addPluginDiros���	
�����,�,� $� 6� 6�7�-�
��	
����A��y�)�S�	
�	
�����+�J�7�9K�L�����_�-�q�1r#z/twisted.python.util.getPluginDirs is deprecated)r�r�N)	rJrKrLr_r�r��SUPPRESSr�rrMr#r!r�r�[s,���
2�
2� 	�'�E�	
�"��r#r�c�L�eZdZdZeej�Zd�Zd�Zd�Z	d�Z
y)�SuppressedWarningsTestsz6
    Tests for L{util.runWithWarningsSuppressed}.
    c���difdifg}|j|tjd�|j|tjd�|jg|j	��y)z�
        Warnings from the function called by C{runWithWarningsSuppressed} are
        suppressed if they match the passed in filter.
        ��ignorez.*foo.*�r�z.*bar.*�
ignore fooz
ignore barN��runWithWarningsSuppressed�warnings�warnrr�)r�filterss  r!�&test_runWithWarningsSuppressedFilteredz>SuppressedWarningsTests.test_runWithWarningsSuppressedFiltered�s^��
*�2�.�1F��0K�L���&�&�w��
�
�|�L��&�&�w��
�
�|�L�����T�/�/�1�2r#c���difdifg}|j|tjd�|jdg|j	�D�cgc]}|d��	c}�ycc}w)z�
        Warnings from the function called by C{runWithWarningsSuppressed} are
        not suppressed if they do not match the passed in filter.
        r�r�zdon't ignorer�Nr��rr�rs   r!�(test_runWithWarningsSuppressedUnfilteredz@SuppressedWarningsTests.test_runWithWarningsSuppressedUnfiltered�s]��
*�2�.�1F��0K�L���&�&�w��
�
�~�N����.�)�$�BT�BT�BV�+W�Q�A�i�L�+W�X��+Ws�	A
c�J�|j|jgd��d�y)zd
        C{runWithWarningsSuppressed} returns the result of the function it
        called.
        c��y)NrrMrMr#r!r{z:SuppressedWarningsTests.test_passThrough.<locals>.<lambda>�r�r#rN)rr�r+s r!�test_passThroughz(SuppressedWarningsTests.test_passThrough�s!��
	
����7�7��I�F��Jr#c���difdifg}|j|d��tjd�|jdg|j	�D�cgc]}|d��	c}�ycc}w)zk
        Once C{runWithWarningsSuppressed} has returned, it no longer
        suppresses warnings.
        r�r�c��yr�rMrMr#r!r{z<SuppressedWarningsTests.test_noSideEffects.<locals>.<lambda>�r�r#r�r�Nr�r�s   r!�test_noSideEffectsz*SuppressedWarningsTests.test_noSideEffects�sb��
*�2�.�1F��0K�L���&�&�w��=��
�
�l�#����,���@R�@R�@T�)U�1�!�I�,�)U�V��)Us�A$
N)rJrKrLr_�staticmethodr
r�r�r�r�r�rMr#r!r�r��s1���!-�T�-K�-K� L��3�Y�K�Wr#r�c�.�eZdZdZd�Zd�Zd�Zd�Zd�Zy)�FancyStrMixinTestsz*
    Tests for L{util.FancyStrMixin}.
    c�v�Gd�dtj�}|jt|��d�y)z�
        If C{showAttributes} is set to a sequence of strings, C{__str__}
        renders using those by looking them up as attributes on the object.
        c��eZdZdZdZdZy)�6FancyStrMixinTests.test_sequenceOfStrings.<locals>.Foo��first�secondr�helloN�rJrKrL�showAttributesr�r�rMr#r!rVr�����0�N��E��Fr#rVz<Foo first=1 second='hello'>N�r
�
FancyStrMixinr�str�rrVs  r!�test_sequenceOfStringsz)FancyStrMixinTests.test_sequenceOfStrings�s-��	�$�$�$�	�
	
����S�U��%C�Dr#c�v�Gd�dtj�}|jdt|���y)a
        If C{showAttributes} has an item that is a 2-tuple, C{__str__} renders
        the first item in the tuple as a key and the result of calling the
        second item with the value of the attribute named by the first item as
        the value.
        c�"�eZdZddd�ffZdZdZy)�.FancyStrMixinTests.test_formatter.<locals>.Foor�r�c�$�t|ddd��S)Nrr)r�)�values r!r{z7FancyStrMixinTests.test_formatter.<locals>.Foo.<lambda>�s���U�4�R�4�[�@Q�r#r��worldNr�rMr#r!rVr��s��%��2Q�'R�S�N��E��Fr#rVz"<Foo first='hello' second='dlrow'>Nr�r�s  r!�test_formatterz!FancyStrMixinTests.test_formatter�s-��	�$�$�$�	�
	
���=�s�3�5�z�Jr#c�v�Gd�dtj�}|jt|��d�y)a&
        If C{showAttributes} has an item that is a 3-tuple, C{__str__} renders
        the second item in the tuple as a key, and the contents of the
        attribute named in the first item are rendered as the value. The value
        is formatted using the third item in the tuple.
        c��eZdZdZdZdZy)�-FancyStrMixinTests.test_override.<locals>.Foo)r�)r��2ndz%.1frg��S�@Nr�rMr#r!rVr��s��A�N��E��Fr#rVz<Foo first=1 2nd=2.1>Nr�r�s  r!�
test_overridez FancyStrMixinTests.test_override�s-��	�$�$�$�	�
	
����S�U��%<�=r#c�v�Gd�dtj�}|jt|��d�y)z_
        If C{fancybasename} is present, C{__str__} uses it instead of the class name.
        c��eZdZdZy)�2FancyStrMixinTests.test_fancybasename.<locals>.Foo�BarN)rJrKrL�
fancybasenamerMr#r!rVr��s��!�Mr#rVz<Bar>Nr�r�s  r!�test_fancybasenamez%FancyStrMixinTests.test_fancybasename�s,��
	"�$�$�$�	"�	
����S�U��W�-r#c��Gd�dtj�}|�}|jt|�t	|��y)zE
        C{__repr__} outputs the same content as C{__str__}.
        c��eZdZdZdZdZy)�)FancyStrMixinTests.test_repr.<locals>.Foor�rr�Nr�rMr#r!rVr��r�r#rVN)r
r�rr�r�)rrV�objs   r!�	test_reprzFancyStrMixinTests.test_repr�s5��
	�$�$�$�	�
�e������S��4��9�-r#N)	rJrKrLr_r�r�r�r�r�rMr#r!r�r��s"���E�
K�
>�.�.r#r�c�:�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
y	)
�
PadToTestsz"
    Tests for L{util.padTo}.
    c�\�tjdg�}|jdgdz|�y)ze
        L{None} values can be added to a list to cause it to have a certain
        length.
        rN�r
�padTor�r�paddeds  r!�test_defaultzPadToTests.test_default�s*��
���A�r�"�����$��!��V�,r#c�^�tjdgd�}|jdgdz|�y)zg
        A specific value can be added to a list to cause it to have a certain
        length.
        rr�Nr�r�s  r!�test_specificDefaultValuez$PadToTests.test_specificDefaultValues,��
���A�r�3�'�����#����F�+r#c�^�tjdddgd�}|jgd�|�y)zl
        A list which already has some items has the padding value added after
        those items.
        rrrr�)rrr�Nr�r�s  r!�test_padNonEmptyListzPadToTests.test_padNonEmptyLists*��
���A��1�v�s�+������f�-r#c�T�|jttjdddg�y)z{
        L{util.padTo} can't pad a list if the size requested is smaller than
        the size of the list to pad.
        rrN)r4r5r
r�r+s r!�test_padToSmallerSizez PadToTests.test_padToSmallerSizes ��
	
���*�d�j�j�!�a��V�<r#c�n�ddg}tjt|�|�}|j||�y)z�
        If the list is already the length indicated by the padding argument
        then a list with the same value is returned.
        rrN)r
r�r�r�rr�r�s   r!�test_alreadyPaddedzPadToTests.test_alreadyPaddeds1��
�A������C��J��.�������'r#c�n�ddg}tjt|�|�}|j||�y)z�
        If the list is already the length indicated by the padding argument
        then the return value is a copy of the input.
        rrN)r
r�r��assertIsNotr�s   r!�test_alreadyPaddedCopiesz#PadToTests.test_alreadyPaddedCopies's1��
�A������C��J��.�������'r#c�X�g}tjd|�|jg|�y)zO
        L{util.padTo} doesn't modify the input list but makes a copy.
        rNr�)rr�s  r!�
test_makeCopyzPadToTests.test_makeCopy0s'�����
�
�1�e������U�#r#N)rJrKrLr_r�r�r�r�r�r�rrMr#r!r�r��s*���-�,�.�=�(�(�$r#r�)Gr_rg�os.pathr7rr�r��typingrrrr�unittestrrC�_grpr5�_pwd�ImportError�twisted.internetr�twisted.internet.deferr	�twisted.internet.errorr
�twisted.internet.interfacesr�twisted.internet.protocolr�twisted.pythonr
�twisted.python.filepathr�twisted.test.test_processr�twisted.trial.unittestrr�twisted.trial.utilrr��
executable�_asBytesPathr�rrOra�getattrrqr�r�r�r��
providedByr�rrrXr8rBrErGrPrSrlr�r�r�r�r�r�rMr#r!�<module>rse��
�

��
�
��>�>�����
�C�
�C�$�+�.�7�5��,�,�5�3����� �-�-�/��.J��.J�bV�x�V�*(�(�(�>�G�B��$�'�'�)F�G�CV�X�CV�H�CV�L]'��]'�@2�x�2�.M-�8�M-�`6�_�6�"�"��"�"�7�+�+�2��7�x�7�	�7�D+��+�.J<��J<�Z	�T�
�
�	�	�d�'�'�	��F������_:�H�_:�D�G�B�	�4�(�(�*I�J�nA�h�nA�K�nA�b�D����N�O�I�h�I�P�I�<(�x�(�V)W�h�)W�XE.��E.�P<$��<$��K��
�C�
�C��s�H�	H�H
Page Not Found
Parece que el enlace que apuntaba aquí no sirve. ¿Quieres probar con una búsqueda?
¡Hola!